﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace laohan.Common.APIInter
{
    /// <summary>
    /// 数据库连接接口
    /// </summary>
    public interface IDBUtility
    {
        /// <summary>
        /// 连接字符串
        /// </summary>
        string ConnectionString
        {
            get;
            set;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        bool ConnectTest();

        /// <summary>
        /// 存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        bool Exists(string strSql);

        /// <summary>
        /// 存在
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        bool Exists(string strSql, params IDataParameter[] cmdParms);

        /// <summary>
        /// 表存在
        /// </summary>
        /// <param name="TableName"></param>
        /// <returns></returns>
        bool TableExists(string TableName);

        /// <summary>
        /// 表中是否存在列
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        bool ColumnExists(string tableName, string columnName);

        /// <summary>
        /// 获取表中的字典最大id
        /// </summary>
        /// <param name="FieldName"></param>
        /// <param name="TableName"></param>
        /// <returns></returns>
        int GetMaxID(string FieldName, string TableName);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="SQLString"></param>
        /// <returns></returns>
        int ExecuteSql(string SQLString);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="Times"></param>
        /// <returns></returns>
        int ExecuteSqlByTime(string SQLString, int Times);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="list"></param>
        /// <param name="oracleCmdSqlList"></param>
        /// <returns></returns>
        int ExecuteSqlTran(List<CommandInfo> list, List<CommandInfo> CmdSqlList);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="SQLStringList"></param>
        /// <returns></returns>
        int ExecuteSqlTran(List<string> SQLStringList);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        int ExecuteSql(string SQLString, string content);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        object ExecuteSqlGet(string SQLString, string content);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="strSQL"></param>
        /// <param name="fs"></param>
        /// <returns></returns>
        int ExecuteSqlInsertImg(string strSQL, byte[] fs);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="SQLString"></param>
        /// <returns></returns>
        object GetSingle(string SQLString);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="Times"></param>
        /// <returns></returns>
        object GetSingle(string SQLString, int Times);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="SQLString"></param>
        /// <returns></returns>
        DataSet Query(string SQLString);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="TableName"></param>
        /// <returns></returns>
        DataSet Query(string SQLString, string TableName);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="TableName"></param>
        /// <returns></returns>
        DataSet Query(List<string> SQLString, List<string> TableName);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="Times"></param>
        /// <returns></returns>
        DataSet Query(string SQLString, int Times);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="dt"></param>
        void Update(DataTable dt);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        int ExecuteSql(string SQLString, params IDataParameter[] cmdParms);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="SQLStringList"></param>
        void ExecuteSqlTran(Hashtable SQLStringList);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="SQLStringList"></param>
        /// <param name="rowsAffected"></param>
        void ExecuteSqlTran(Hashtable SQLStringList, out int rowsAffected);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="cmdList"></param>
        /// <returns></returns>
        int ExecuteSqlTran(List<CommandInfo> cmdList);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="SQLStringList"></param>
        void ExecuteSqlTranWithIndentity(List<CommandInfo> SQLStringList);

        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="SQLStringList"></param>
        void ExecuteSqlTranWithIndentity(Hashtable SQLStringList);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        object GetSingle(string SQLString, params IDataParameter[] cmdParms);

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="SQLString"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        DataSet Query(string SQLString, params IDataParameter[] cmdParms);

        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName"></param>
        /// <param name="parameters"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName);

        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName"></param>
        /// <param name="parameters"></param>
        /// <param name="tableName"></param>
        /// <param name="Times"></param>
        /// <returns></returns>
        DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName, int Times);

        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName"></param>
        /// <param name="parameters"></param>
        /// <param name="rowsAffected"></param>
        /// <returns></returns>
        int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected);

        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="storedProcName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        int RunProcedureRowsAffected(string storedProcName, IDataParameter[] parameters);
    }
}
